package com.njwb.day06;

public class TestFinal {
    public static void main(String[] args) {
        C c=new C();
        c.fn1();
        c.fn2();
    }
}
//断子绝孙类/太监类
/*class A extends B{

}
final class B{

}*/

class C extends D{
    public void fn1(){
        System.out.println("C.fn1");
    }
    //final修饰的方法不能被子类重写
    /*void fn2(){
        System.out.println("D.fn2");
    }*/
}
class D{
    final int i=1;
    public void fn1(){
        System.out.println("D.fn1");
    }

    public final void fn2(){
        final int j;
        j=2;
        //final修饰的变量初始化值后不可改变
        //i=10;
        //j=20;
        System.out.println("D.fn2");
        System.out.println(i);
        System.out.println(j);
    }
}
